package com.hcw.bankdemo.exception;

/**
 * 异常枚举类
 */
public enum ExceptionEnum {
    SERVER_UpMoney_ERROR                ("0001","扣钱失败"),
    SERVER_Money_ERROR        ("0002","余额不足"),
    SERVER_From_RPC_ERROR    ("0003","转款逆向接口调用失败"),
    SERVER_TRANT_ERROR            ("0004","事务异常"),
    SERVER_To_RPC_ERROR                ("0005","收款逆向接口调用失败"),
    SERVER_OTHER_ERROR            ("1099","其他异常");

    private String ecode;

    private String emsg;

    ExceptionEnum(String ecode, String emsg) {
        this.ecode = ecode;
        this.emsg = emsg;
    }

    public String getEcode() {
        return ecode;
    }

    public String getEmsg() {
        return emsg;
    }

    public static ExceptionEnum statOf(String ecode) {
        for (ExceptionEnum state : values())
            if (state.getEcode().equals(ecode))
                return state;
        return null;
    }
}
